package com.tuo51.manager.vo;

import com.tuo51.evaluate.domain.news.ArticleCategory;
import com.tuo51.foudation.utils.CopyUtils;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.thymeleaf.util.ListUtils;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Data
@NoArgsConstructor
public class ArticleCategoryVO {

    private String id;//用户id

    private boolean deleted;

    private Date created;
    private String title;

    private String channel;

    private String tags;

    private String staticCode;

    private int orderWeight;

    private Boolean vip = false;

    private Boolean hidden = false;

    private List<ArticleCategoryVO> subCategories;

    public static ArticleCategoryVO of(ArticleCategory obj){
        ArticleCategoryVO ret = new ArticleCategoryVO();

        CopyUtils.copyProperties(obj, ret);
        if (!ListUtils.isEmpty(obj.getSubCategories())) {
            ret.setSubCategories(obj.getSubCategories().stream().map(k->ArticleCategoryVO.of(k)).collect(Collectors.toList()));
        }

        return ret;
    }
}
